﻿using System;
using System.Collections.Generic;

using System.Text;
using System.IO;

namespace LogScrubberCommon
{
    public class Scrubber
    {
        public static void Scrub(string inFile, string outFile, List<string> ScrubKeys)
        {
            StreamReader srInFile = System.IO.File.OpenText(inFile);
            StreamWriter swOutFile = System.IO.File.CreateText(outFile);

            swOutFile.AutoFlush = true;

            while (!srInFile.EndOfStream)
            {
                string logLine = srInFile.ReadLine();

                bool writeOut = true;

                foreach (string key in ScrubKeys)
                {

                    if (logLine.ToLower().Contains(key.ToLower()))
                    {
                        writeOut = false;
                        break;
                    }

                }
                if (writeOut)
                {
                    swOutFile.WriteLine(logLine);
                }

            }

            srInFile.Close();
            swOutFile.Close();

        }
    }
}
